import Vue from 'vue'
// 导入vue-router插件
import VueRouter from 'vue-router'

// 注册vue-router插件
Vue.use(VueRouter)

// 定义路由表
const routes = [
  {
    path: '/',
    name: 'home',
    component: () => import('../views/HomeView.vue'),
    children: [
      {
        path: '/home/abnor',
        name: 'abnor',
        component: () => import('../views/Home/Abnormal.vue')
      },
      {
        path: '/home/index',
        name: 'index',
        component: () => import('../views/Home/Index.vue')
      },
      {
        path: '/home/publi',
        name: 'publi',
        component: () => import('../views/Home/Publicity.vue')
      },
      {
        path: '/home/query',
        name: 'query',
        component: () => import('../views/Home/Query.vue')
      },
      {
        path: '/home/record',
        name: 'record',
        component: () => import('../views/Home/Record.vue')
      },
      {
        path: '/home/reports',
        name: 'reports',
        component: () => import('../views/Home/Reports.vue')
      },
      {
        path:'/home',
        redirect:'/home/index'
      }
    ]
  },
  {
    path: '/login',
    name: 'login',
    component: () => import('../views/Login.vue') // 动态加载（懒加载）
  },
  {
    path:'/',
    redirect:'/home' // 重定向
  },
  {
    path:'*',
    component: () => import('../views/Notfound.vue')
  }
]
// 动态路由传参 ,比如 '/home/reports:name'   :name是个占位符，实际跳路由的时候，会动态拼接参数

// 实例化路由对象
const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

// 导出路由对象
export default router
